const store = {
    state: {
        num: 20
    },
    // 这里只放同步方法，异步使用redux-thunk
    actions: {
        add1(newState: { num: number }, action: { type: string }) {
            newState.num++
        },
        test(newState: { num: number }, action: { type: string, val: number }) {
            newState.num += action.val
        }
    } as any,
    // 异步方法,优化redux-thunk写法
    asyncActions: {
        asyncAdd1(dis: Function) {
            setTimeout(() => {
                dis({ type: "add1" })
            }, 1000);
        }
    },
    actionsNames: {} as any

}
let actionNames: any = {}
// 遍历store，有多少键值对，取决于actions的函数
for (let key in store.actions) {
    actionNames[key] = key
}
store.actionsNames = actionNames
export default store